gdkwindow: Fix potential NULL pointer dereferences in event code
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 20 Nov 2013 17:21:28 +0000 (17:21 +0000)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Sun, 7 Aug 2016 07:17:50 +0000 (08:17 +0100)
The event code could potentially dereference pointer_info if the
invariant that ENTER_NOTIFY and LEAVE_NOTIFY events are only emitted on
devices which have pointers is violated elsewhere.

Found with scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=712760

gdk/gdkwindow.c

index aa28e4aa954bd145274f88e22c27afc374bee433..186478bc9ef5cc0f57dd8f1939a19a8986901867 100644 (file)
@@ -9935,7 +9935,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
       /* We ended up in this window after some (perhaps other clients)
        * grab, so update the toplevel_under_window state
        */
-      if (is_toplevel &&
+      if (pointer_info && is_toplevel &&
           event->type == GDK_ENTER_NOTIFY &&
           event->crossing.mode == GDK_CROSSING_UNGRAB)
         {
@@ -9949,7 +9949,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
     }
 
   /* Track toplevel_under_pointer */
-  if (is_toplevel)
+  if (pointer_info && is_toplevel)
     {
       if (event->type == GDK_ENTER_NOTIFY &&
           event->crossing.detail != GDK_NOTIFY_INFERIOR)